package cn.itsource.ymcc.mq;

import cn.itsource.ymcc.domain.MediaFile;
import com.alibaba.fastjson.JSON;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.client.producer.SendStatus;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;

public class MessageProducer {
    @Autowired
    private RocketMQTemplate rocketMQTemplate;
    public boolean sendMessage(MediaFile mediaFile){
        //方便消费方封装
        String s = JSON.toJSONString(mediaFile);

        SendResult sendResult = rocketMQTemplate.syncSend("media-topic:media-tags", mediaFile);
        SendStatus sendStatus = sendResult.getSendStatus();
        return sendStatus==SendStatus.SEND_OK;

    }
}
